<template>
  <el-drawer v-model="addDrawer" size="45%" :show-close="false" @opened="openDrawer" @close="closeDrawer">
    <template #title>
      <h2><svg-icon icon-class="list"></svg-icon><span style="padding-left: 15px">{{typeName}}</span></h2>
      <el-button type="primary" @click="confirmClick" :disabled="drawerLoading" v-if="isShowSave">保存</el-button>
    </template>
    <template #default>
      <el-form :model="form" ref="addRef" :inline="true" :rules="formRules" label-width="140px" v-loading="drawerLoading">
        <el-row justify="space-between">
          <el-form-item label="省">
            <el-input v-model="form.province" clearable disabled></el-input>
          </el-form-item>
          <el-form-item label="市">
            <el-input v-model="form.city" clearable disabled></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="区/县">
            <el-input v-model="form.county" clearable disabled></el-input>
          </el-form-item>
          <el-form-item label="点编号" prop="id">
            <el-input v-model="form.id" placeholder="请输入点编号" clearable maxlength="17"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="目标区编号" prop="targetRegionId">
            <el-input v-model="form.targetRegionId" placeholder="请输入目标区编号" clearable maxlength="17"></el-input>
          </el-form-item>
          <el-form-item label="加速度峰值1" prop="pgaNs">
            <el-input v-model="form.pgaNs" placeholder="请输入加速度峰值1" clearable maxlength="8"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="加速度峰值2" prop="pgaEw">
            <el-input v-model="form.pgaEw" placeholder="请输入加速度峰值2" clearable maxlength="8"></el-input>
          </el-form-item>
          <el-form-item label="加速度峰值3" prop="pgaUd">
            <el-input v-model="form.pgaUd" placeholder="请输入加速度峰值3" clearable maxlength="8"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="速度峰值1" prop="pgvNs">
            <el-input v-model="form.pgvNs" placeholder="请输入速度峰值1" clearable maxlength="8"></el-input>
          </el-form-item>
          <el-form-item label="速度峰值2" prop="pgvEw">
            <el-input v-model="form.pgvEw" placeholder="请输入速度峰值2" clearable maxlength="8"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="速度峰值3" prop="pgvUd">
            <el-input v-model="form.pgvUd" placeholder="请输入速度峰值3" clearable maxlength="8"></el-input>
          </el-form-item>
          <el-form-item label="位移峰值1" prop="pgdNs">
            <el-input v-model="form.pgdNs" placeholder="请输入位移峰值1" clearable maxlength="8"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="位移峰值2" prop="pgdEw">
            <el-input v-model="form.pgdEw" placeholder="请输入位移峰值2" clearable maxlength="8"></el-input>
          </el-form-item>
          <el-form-item label="位移峰值3" prop="pgdUd">
            <el-input v-model="form.pgdUd" placeholder="请输入位移峰值3" clearable maxlength="8"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="备注" prop="commentInfo" style="width:100%">
            <el-input v-model="form.commentInfo" placeholder="请输入备注" :autosize="{ minRows: 3, maxRows: 6 }"
              type="textarea" show-word-limit maxlength="2147483647" clearable></el-input>
          </el-form-item>
        </el-row>
      </el-form>
    </template>
  </el-drawer>
</template>
<script setup>
import useSpatialData from '@/hooks/useSpatialData'
import { eightDouble } from '@/utils/validate'
const { route, addDrawer, drawerLoading, form, typeName, openDrawer, closeDrawer, confirmClick, isShowSave } = useSpatialData()

const formRules = {
  id: [{ required: true, message: '请填写点编号！', trigger: 'blur' }],
  targetRegionId: [{ required: true, message: '请填写目标区编号！', trigger: 'blur' }],
  pgaNs: [eightDouble],
  pgaEw: [eightDouble],
  pgaUd: [eightDouble],
  pgvNs: [eightDouble],
  pgvEw: [eightDouble],
  pgvUd: [eightDouble],
  pgdNs: [eightDouble],
  pgdEw: [eightDouble],
  pgdUd: [eightDouble]
}
</script>
<style scoped></style>